﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Policy;
using System.Threading;
using System.Windows.Forms;

namespace Kugar.Core.WinForm
{
    public class ApplicationInfo
    {
        /// <summary>
        ///     当前程序是否已经有运行实例
        /// </summary>
        /// <returns>如果已存在相同的实例,则返回true,否则返回false</returns>
        public static bool IsHasRuningInstance()
        {
            
            bool isAppRunning;

            var m = new Mutex(false, Process.GetCurrentProcess().ProcessName, out isAppRunning);

            return !m.WaitOne(50, false) ;
        }

    }
}
